open other modules in DXL

I have a module,ModuleA, that I want to read from that has two columns, c1 and c2. The first column contains an ID let's call it ModuleBID that I want to search and find in ModuleB, and the second column has another ID called ModuleCID that I want to search and find in ModuleC. When the matching Id's ModuleBID , and ModuleCID are found in ModuleB & ModuleC respectively I want to create a link between them.

I know how to create the links between the two modules but I am having trouble gaining access to Modules B & C. When I run my script, I open Module A and then run from there. The code below is simplified...
for aObj in ModuleA do
{
//get ModuleBID and ModuleCID
//how do I gain access to ModuleB and ModuleC to search?? The following is what I'm
//doing but isn't working

bMod = edit("ModuleB")
//when I try to view name(bMod) I get a null error
for bObj in bMod
{
if(ModuleBID matches a column called ID in ModuleB)
{
record bObj for later use
}
}
//do the same for ModuleC and record cObj

//create link between bObj and cObj

}
lsand - Fri Jul 09 19:17:32 EDT 2010

Re: open other modules in DXL
llandale - Sun Jul 11 19:46:34 EDT 2010

You will need the full path to module B and C; unless by chance they are in the same folder as module A and your DXL is running from within module A.

You probably want to open B execlusive (source links) and C read (target links)

Try something like this:

// Open module A, then run this code
Module mCurr = current
if (null mCurr     or 
    type(mCurr) != "Formal"   or
    name(mCurr) != "Module!") {errorBox("Run from open moduleA"); halt}
 
string NameB = "/MyProject/MyFolder/ModuleB",
       NameC = "/MyProject/MyOtherFolder/ModuleC"
 
Module modB  = edit(NameB, false, false)
if (null modB) {errorBox("Cannot open " NameB); halt}
elseif(!isEdit(modB)) {errorBox("Cannot open " NameB " for edit"); close(modB); halt}
 
Module modC = read(NameC, false)
if (null modC) {errorBox("Cannot open " NameC); close(modB); halt}
 
// OK, here we go

 

 

  • Louie